package com.woniuxy.rms.dao;

import com.woniuxy.rms.pojo.Servers;
import com.woniuxy.rms.util.DataResult;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

public interface ServersMapper {
    int deleteByPrimaryKey(Long id);

    int insert(Servers record);

    int insertSelective(Servers record);

    Servers selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(Servers record);

    int updateByPrimaryKey(Servers record);

    /**
     * Description : 根据服务菜单id查找入驻商家或者物业  <br/>
     * ChangeLog : 1. 创建 (2020/3/27 0027 下午 6:57 [Administrator]);
     * @param menuIds
     * @return java.util.List<com.woniuxy.rms.pojo.Servers>
    */
    List<Servers> findByMenuIds(List<Long> menuIds);

    /**
     * Description : 查询物业入驻信息  <br/>
     * ChangeLog : 1. 创建 (2020/3/27 0027 下午 9:12 [Administrator]);
     * @param currentPage
     * @param pageSize
     * @param serverType
     * @return java.util.List<com.woniuxy.rms.pojo.Servers>
     */
    @Select("select servers.*,server_menu.server_name,property.account from servers left join server_menu on servers.server_menu_id = server_menu.id " +
            "left join property on property.id = servers.supplier_id where servers.server_type = #{serverType}")
    List<Servers> findProByPage(@Param("currentPage") Integer currentPage,@Param("pageSize")
            Integer pageSize,@Param("serverType") Integer serverType);
    /**
     * Description : 入驻审核  <br/>
     * ChangeLog : 1. 创建 (2020/3/27 0027 下午 7:25 [Administrator]);
     * @param id
     * @param status  0-待审核 1-审核通过
     * @param date
     * @return void
     */
    @Update("update servers set enter_status = #{status},enter_time = #{date} where id = #{id}")
    void checkStatus(@Param("id") Long id, @Param("status") Integer status,@Param("date") Date date);

    /**
     * Description : 查询商户入驻信息  <br/>
     * ChangeLog : 1. 创建 (2020/3/27 0027 下午 9:12 [Administrator]);
     * @param currentPage
     * @param pageSize
     * @param serverType
     * @return java.util.List<com.woniuxy.rms.pojo.Servers>
    */
    @Select("select servers.*,server_menu.server_name,vendor.account from servers left join server_menu on servers.server_menu_id = server_menu.id " +
            "left join vendor on vendor.id = servers.supplier_id where servers.server_type = #{serverType}")
    List<Servers> findVentorByPage(@Param("currentPage") Integer currentPage,@Param("pageSize")
            Integer pageSize,@Param("serverType") Integer serverType);

    /**
     * Description : 批量删除入驻用户  <br/>
     * ChangeLog : 1. 创建 (2020/3/27 0027 下午 9:30 [Administrator]);
     * @param serverIds
     * @return void
    */
    void batchDelEnter(List<Long> serverIds);
}